package mtt.us.client.views.fachbereich.studiengang.editor;

import mtt.us.client.events.GetModelDataEvent;
import mtt.us.client.views.fachbereich.events.ShowStudiengangViewEvent;
import mtt.us.client.views.fachbereich.studiengang.events.ShowStudiengangEditorEvent;
import mtt.us.hmvcFramework.client.hmvc.events.AddViewEvent;
import mtt.us.hmvcFramework.client.hmvc.events.DisposeEvent;
import hmvc4gwt.client.controller.Controller;
import hmvc4gwt.client.event.HmvcEvent;
import hmvc4gwt.client.event.HmvcEventListener;

public class StudiengangEditorController extends Controller implements HmvcEventListener {

	public void doInit() {
		
		register(ShowStudiengangEditorEvent.class, this);
		register(DisposeEvent.class, this);
	}

	public void handleEvent(HmvcEvent event) {
		
		if (event instanceof ShowStudiengangEditorEvent) {
			
			fireLocalEvent(new GetModelDataEvent());
			
			fireEvent(new AddViewEvent(getView()), true, false, false);
			
		} else if (event instanceof DisposeEvent) {
			getTriad().dispose();
		}
		
	}
	
	public void dispose() {
		fireEvent(new ShowStudiengangViewEvent(), true, false, false);
	}
	
}
